package xuhaijia.lanou3g.autohome.myself;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;
import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.base.BaseActivity;

/**
 * Created by 7 on 16/8/29.
 */
public class RegisterActivity extends BaseActivity implements View.OnClickListener {

    private Button finishRegister;
    private EditText account;
    private EditText password;

    @Override
    protected int setLayout() {
        return R.layout.activity_register;
    }

    @Override
    protected void initView() {
        account = bindView(R.id.register_account);
        password = bindView(R.id.register_password);
        finishRegister = bindView(R.id.finish_register);
        finishRegister.setOnClickListener(this);
    }

    @Override
    protected void initData() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.finish_register:
                //尽快更换过
                BmobUser bmobUser = new BmobUser();
                bmobUser.setUsername(account.getText().toString());
                bmobUser.setPassword(password.getText().toString());
                bmobUser.signUp(new SaveListener<BmobUser>() {
            @Override
            public void done(BmobUser bmobUser, BmobException e) {
                if (e == null) {
                    Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
                    finish();
                } else {
                    Toast.makeText(RegisterActivity.this, "注册失败,请检查你的网络", Toast.LENGTH_SHORT).show();
                }
            }
        });

                break;
        }
    }
}
